// gulp的入口文件
const fs = require('fs');
const { Transform } = require('stream');

exports.default = () => {
  // 读入流
  const readStream = fs.createReadStream('package.json');
  // 写入流
  const writeStream = fs.createWriteStream('demo13.text');
  // 转换流
  const transformStream = new Transform({
    transform: (chunk, encoding, callback) => {
      const input = chunk.toString();
      const output = input.replace(/\s+/g, '').replace(/\/\*.+?\*\//g, '');//去掉空格，注释
      callback(null, output)
    }
  })

  readStream.pipe(transformStream).pipe(writeStream);

  return readStream;
}

